//
//  CashAdvanceViewController.m
//  BigJoy
//
//  Created by Rowling on 2017/6/20.
//  Copyright © 2017年 Rowling. All rights reserved.
//

#import "CashAdvanceViewController.h"
#import "CheckPhoneView.h"
#import "JKCountDownButton.h"

@interface CashAdvanceViewController ()

@end

@implementation CashAdvanceViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"提现";
    [self addLiftButton];
}

-(void)addLiftButton {
    UIButton * button = [[UIButton alloc]init];
    [button setTitle:@"更换绑定" forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont systemFontOfSize:15];
    [button sizeToFit];
    [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:button];
    @weakify(self);
    [[button rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
        @strongify(self);
        CheckPhoneView * checkView = [CheckPhoneView fastLogin];
        checkView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
        [checkView.getCodeButton addTarget:self action:@selector(getCodeClick:) forControlEvents:UIControlEventTouchUpInside];
        [XMKEYWINDOWXM addSubview:checkView];
    }];
}

-(void)getCodeClick:(JKCountDownButton *)sender {
    
    [sender startCountDownWithSecond:20];
    sender.enabled = NO;
    [sender countDownChanging:^NSString *(JKCountDownButton *countDownButton,NSUInteger second) {
        NSString *title = [NSString stringWithFormat:@"剩余%zd秒",second];
        return title;
    }];
    [sender countDownFinished:^NSString *(JKCountDownButton *countDownButton, NSUInteger second) {
        countDownButton.enabled = YES;
        return @"点击重新获取";
    }];
}
- (IBAction)CashAdvanceButtonClick:(id)sender {
    [CustomAlerView showAlertMessage:@"成功提交提现申请，提现金额将在2-7个工作日入账到您的微信钱包!"];
}


@end
